﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YRevitJig;

namespace YJKRevitPipeSetting.Utiltiy
{
	public class YRevitJigExtend : XLineJig
	{
		public YRevitJigExtend(UIDocument uiDoc) : base(uiDoc)
		{
			base.ResetPoint = XUiJigBase.EResetPoint.eByAxis;
			this.SetWidth(2.0);
		}

		private void setMode(bool ifAxis = true)
		{
			if (ifAxis)
			{
				base.ResetPoint = XUiJigBase.EResetPoint.eByAxis;
				return;
			}
			base.ResetPoint = XUiJigBase.EResetPoint.eNoOper;
		}

		internal double NowWidth
		{
			get
			{
				return YRevitJigExtend.nowWidth;
			}
		}

		internal void SetWidth(double input)
		{
			YRevitJigExtend.nowWidth = input;
			base.MutilLineDist.Clear();
			if (input > 0.0)
			{
				base.MutilLineDist.Add(YRevitJigExtend.nowWidth / 2.0);
				base.MutilLineDist.Add(YRevitJigExtend.nowWidth / 2.0);
			}
		}

		internal void SetPos(double input)
		{
			if (input == 3.0)
			{
				base.PointAlignType = XLineJig.AlignType.eLeft;
				return;
			}
			if (input == 1.0)
			{
				base.PointAlignType = XLineJig.AlignType.eRight;
				return;
			}
			if (input == 2.0)
			{
				base.PointAlignType = XLineJig.AlignType.eMiddle;
			}
		}

		public XYZ PickSrartPointEX(string strPrompt = "请确定直线起点：")
		{
			base.StartPoint = null;
			return base.PickStartPoint(strPrompt);
		}

		public XYZ PickEndPointEX(XYZ ptStart, string strPrompt = "请确定直线终点：", bool ifsingle = false)
		{
			base.EndPoint = null;
			if (!ifsingle)
			{
				return base.PickEndPoint(ptStart, strPrompt);
			}
			this.setMode(false);
			double width = YRevitJigExtend.nowWidth;
			this.SetWidth(0.0);
			XYZ result = base.PickEndPoint(ptStart, strPrompt);
			this.SetWidth(width);
			this.setMode(true);
			return result;
		}

		private static double nowWidth = 2.0;
	}
}
